import { v4 as uuid4 } from 'uuid';
/**
 * @desc 绘制点位数据
 * @param {*} data
 * @returns
 */
export const transData = (data) => {
  let returnData = [];
  if (data && Array.isArray(data) && data.length) {
    let returnItem = null;
    data.map((item) => {
      returnItem = {
        positions: item.positions,
        id: item.id || uuid4(),
        overlayType: 'Polygon',
        style: {
          color: item.color || '#6bffff',
          weight: 1,
          opacity: 1,
          fillOpacity: 0.5,
          // dashArray: '3, 6',
          // dashOffset: null,
          fillColor: item.color,
          fillOpacity: 1,
        },
        label: item.name,
        // 标注样式
        labelStyle: {
          color: item.color || '#6bffff',
          fontSize: '14px',
          fontWeight: 'bold',
        },
        payload: {
          ...item,
        },
      };
      returnData.push(returnItem);
    });
  }
  return returnData;
};
